﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLNS.Class;

namespace QLNS.NghiepVu


{
    public partial class frmQuanLyHopDongLaoDong : Form
    {
        public frmQuanLyHopDongLaoDong()
        {
            InitializeComponent();
        }
        DB cn = new DB();
        private static string _MaNhanVien = "";
        //private static string _HoTen = "";
        //private static string _NgaySinh = "";
        //private static string _Diachi = "";
        //private static string _TotNghiepTruong = "";
        //private static string _ChuyenNganh = "";
        private static string _MaHopDong = "";
        private static string _LoaiHD = "";
        private static string _NgayKy = "";
        private static string _NgayHetHan= "";
        private static string _ChucVu = "";
        private static string _ToMon = "";
        private static string _PhuCap = "";
        private static string _ThoiGian = "";
        private static string _BacLuong = "";

      
        private void fmrQuanLyHopDongLaoDong_Load(object sender, EventArgs e)
        {
            cn.KetNoi();
            load_dtgHopDong();

        }
        private void load_dtgHopDong()
        {
            DataTable tbl = cn.getTable("select *from HopDong");
            dtgHopDong.DataSource = tbl;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmThemHopDongLaoDong frmThemHopDongLaoDong = new frmThemHopDongLaoDong();
            frmThemHopDongLaoDong.ShowDialog();
            load_dtgHopDong();
        }

        private void btnSua_Click(object sender, EventArgs e)
        {
            _MaHopDong=dtgHopDong.CurrentRow.Cells["MaHopDong"].Value.ToString();
            _MaNhanVien = dtgHopDong.CurrentRow.Cells["MaNhanVien"].Value.ToString(); 
            _LoaiHD  = dtgHopDong.CurrentRow.Cells["MaLoaiHopdong"].Value.ToString();
            _NgayKy  = dtgHopDong.CurrentRow.Cells["NgayKy"].Value.ToString();
            _NgayHetHan  = dtgHopDong.CurrentRow.Cells["NgayHetHan"].Value.ToString();
            _ChucVu  = dtgHopDong.CurrentRow.Cells["MaChucVu"].Value.ToString();
            _ToMon  = dtgHopDong.CurrentRow.Cells["MaToMon"].Value.ToString();
            _PhuCap  = dtgHopDong.CurrentRow.Cells["MaPhuCap"].Value.ToString();
            _ThoiGian  = dtgHopDong.CurrentRow.Cells["ThoiGianLamViec"].Value.ToString();
            _BacLuong  = dtgHopDong.CurrentRow.Cells["MaBacLuong"].Value.ToString();

            frmSuaHopDong frm = new frmSuaHopDong();
            frm.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult h = MessageBox.Show("Bạn có muốn xóa không?","Thông báo",MessageBoxButtons.YesNo,MessageBoxIcon.Question );
            if(h==DialogResult.Yes )
            {
                cn.KetNoi();
                cn.Delete_Table("HopDong","MaHopDong='"+dtgHopDong.CurrentRow.Cells["MaHopDong"].Value.ToString()+"'");
                MessageBox.Show("Xóa dữ liệu thành công");
                load_dtgHopDong();
            }
        }


    }
}
